package com.ruoyi.menuOrders.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.menuOrders.domain.MenuOrders;
import com.ruoyi.menuOrders.service.IMenuOrdersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 点菜订单Controller
 * 
 * @author shz
 * @date 2024-07-17
 */
@RestController
@RequestMapping("/menuOrders/menuOrders")
public class MenuOrdersController extends BaseController
{
    @Autowired
    private IMenuOrdersService menuOrdersService;

    /**
     * 查询点菜订单列表
     */
    @PreAuthorize("@ss.hasPermi('menuOrders:menuOrders:list')")
    @GetMapping("/list")
    public TableDataInfo list(MenuOrders menuOrders)
    {
        startPage();
        List<MenuOrders> list = menuOrdersService.selectMenuOrdersList(menuOrders);
        return getDataTable(list);
    }

    /**
     * 导出点菜订单列表
     */
    @PreAuthorize("@ss.hasPermi('menuOrders:menuOrders:export')")
    @Log(title = "点菜订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MenuOrders menuOrders)
    {
        List<MenuOrders> list = menuOrdersService.selectMenuOrdersList(menuOrders);
        ExcelUtil<MenuOrders> util = new ExcelUtil<MenuOrders>(MenuOrders.class);
        util.exportExcel(response, list, "点菜订单数据");
    }

    /**
     * 获取点菜订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('menuOrders:menuOrders:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(menuOrdersService.selectMenuOrdersById(id));
    }

    /**
     * 新增点菜订单
     */
    @PreAuthorize("@ss.hasPermi('menuOrders:menuOrders:add')")
    @Log(title = "点菜订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MenuOrders menuOrders)
    {
        return toAjax(menuOrdersService.insertMenuOrders(menuOrders));
    }

    /**
     * 修改点菜订单
     */
    @PreAuthorize("@ss.hasPermi('menuOrders:menuOrders:edit')")
    @Log(title = "点菜订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MenuOrders menuOrders)
    {
        return toAjax(menuOrdersService.updateMenuOrders(menuOrders));
    }

    /**
     * 删除点菜订单
     */
    @PreAuthorize("@ss.hasPermi('menuOrders:menuOrders:remove')")
    @Log(title = "点菜订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(menuOrdersService.deleteMenuOrdersByIds(ids));
    }



}
